<template>
  <div>
    <!-- 面包屑导航区 -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>数据统计</el-breadcrumb-item>
      <el-breadcrumb-item>和分期</el-breadcrumb-item>
    </el-breadcrumb>

    <!-- 卡片视图 -->
    <el-card>
      <el-row :gutter="20">
        <el-col :span="8">
          <el-radio-group v-model="querInfo.radio">
            <el-radio :label="1">区域分布</el-radio>
            <el-radio :label="2">通报表</el-radio>
            <el-radio :label="3">龙虎榜</el-radio>
          </el-radio-group>
        </el-col>
        <el-col :span="10" style="text-align:center">
          <!-- 日期筛选 -->
          <el-date-picker
            v-model="querInfo.date"
            type="daterange"
            align="right"
            unlink-panels
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
            :picker-options="pickerOptions"
            @change="datechange"
          ></el-date-picker>
        </el-col>
      </el-row>
      <!--2 为 ECharts 准备一个具备大小（宽高）的 DOM -->
      <div id="main" style="width: 600px;height:400px; margin-top:50px;font-size:12px;"></div>
    </el-card>
  </div>
</template>

<script>
// 1 引入echarts包
import echarts from 'echarts'
// 合并对象
// import _ from 'lodash'
export default {
  data() {
    return {
      // 条件
      querInfo: {
        radio: 1,
      },
      // 日期快捷选择
      pickerOptions: {
        shortcuts: [
          {
            text: '最近一周',
            onClick(picker) {
              const end = new Date()
              const start = new Date()
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 7)
              picker.$emit('pick', [start, end])
            },
          },
          {
            text: '最近一个月',
            onClick(picker) {
              const end = new Date()
              const start = new Date()
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 30)
              picker.$emit('pick', [start, end])
            },
          },
          {
            text: '最近三个月',
            onClick(picker) {
              const end = new Date()
              const start = new Date()
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 90)
              picker.$emit('pick', [start, end])
            },
          },
        ],
      },
    }
  },
  created() {},
  // 此时页面上的元素 已经被渲染
  async mounted() {
    // 3 基于准备好的dom，初始化echarts实例
    var myChart = echarts.init(document.getElementById('main'))

    const { data: res } = await this.$http.get('hx/hfqports')
    if (res.meta.status !== 200) {
      return this.$message.error(res.meta.msg)
    }

    // 4指定图表的配置项和数据
    // const result = _.merge(res.data, this.options)

    // 5 使用刚指定的配置项和数据显示图表。
    myChart.setOption(res.data)
  },
  methods: {
    // 日期选择框变化触发搜索
    datechange(d) {},
  },
}
</script>

<style lang="less" scoped>
</style>